package com.ap.core.bulkupload.resource;

import java.io.IOException;

import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;

import org.springframework.core.io.Resource;
import org.xml.sax.SAXException;

/**
 * The Class ResourceLocation.
 */
public class ResourceLocation {
	
	/** The schema. */
	private Schema schema;
	

	/** The xsd resource. */
	private Resource xsdResource;
	

	/**
	 * Gets the schema.
	 *
	 * @return the schema
	 */
	public Schema getSchema() {
		return schema;
	}
	
	/**
	 * Sets the schema factory.
	 *
	 * @param schemaFactory the new schema factory
	 * @throws SAXException the sAX exception
	 * @throws IOException Signals that an I/O exception has occurred.
	 */
	public void setSchemaFactory(SchemaFactory schemaFactory) throws SAXException, IOException {
		schema =  schemaFactory.newSchema(new StreamSource(xsdResource.getInputStream()));
	}	
	
	/**
	 * Gets the xsd resource.
	 *
	 * @return the xsd resource
	 */
	public Resource getXsdResource() {
		return xsdResource;
	}	
	
	/**
	 * Gets the xsd resource.
	 *
	 * @param xsdResource the new xsd resource
	 * @return the xsd resource
	 */
	public void setXsdResource(Resource xsdResource) {
		 this.xsdResource = xsdResource;
	}	
}
